Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

628
Vistas
" Uncaught (in promise) FirebaseError: Invalid document reference. Document references must have an even number of segments,but Users has 1." Reactjs

I am trying to get the data from firebase version9.8 in react.js project, but I am getting the error:

Uncaught (in promise) FirebaseError: Invalid document reference. Document references must have an even number of segments, but Users has 1.

how can I resolve this?

( I want to get the write the data in firebase on submit button so so i write the code in onSubmitHandler )

const onSubmitHandler = async (event) => {  
    console.log(event);
    console.log("saving data to database request is Trigered...")
    // Hear we push the data in firestore databae

    await setDoc(doc(db, "Users",), {

      name:collectionOfStates},{merge: true}


      
    ).then(() => console.log("Data Save in firebase")).catch((error) => {
      console.log(error);
    })

  }
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Your code tries to write data into the Users collection, instead of in a document under it, which is not possible.

If you want to write to a specific, known document, specify its document ID in the call to doc:

                      // 👇
setDoc(doc(db, "Users", "idOfDoc"), {
  name:collectionOfStates},{merge: true}    
)

If you want to add a new document to the collection with an auto-generated ID, use addDoc instead of setDoc:

// 👇
addDoc(doc(db, "Users"), {
  name:collectionOfStates},{merge: true}    
)
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda